package com.skstudio.reportview;

import com.skstudio.report.ReportBase;
import com.skstudio.report.ReportThreads;
import com.skstudio.report.ReportThreads.ThreadClass;
import com.skstudio.report.SpyData;

public class ReporterProcessThread extends ReportViewController {

    ReportThreads mThreads = null;

    public ReportThreads getThreads() {
        return mThreads;
    }

    @Override
    public void setSpyData(SpyData ref) {
        super.setSpyData(ref);
        mThreads = ref.getReportThreads();
    }

    @Override
    public int getReportRows() {
        return mThreads.mDataList.size();
    }

    @Override
    public int getReportColumns() {
        return ReportBase.mRecordCount;
    }

    @Override
    public int getEntry(int row, int col) {
        ThreadClass tc = mThreads.mDataList.get(row);

        if ((col - tc.mStartedFrom) < 0) return -1; //thread not started yet
        if ((col - tc.mStartedFrom) < tc.mThreadDataQueue.size()) {
            return (int)tc.getThreadCpuUsage(col - tc.mStartedFrom);
        }
        if ((col - tc.mStartedFrom) == tc.mThreadDataQueue.size()) {
            return 0; // make the curve touch down
        }
        return -1; //thread is dead;
    }

    @Override
    public String stringYLabels(int id) {
        return Integer.toString(id * 10) + "%";
    }
}
